import { IDispose } from "../../gengine/core/IDispose";
import { UICompomentPool } from "../utils/UICompomentPool";
import { GTextFiled } from "./GTextFiled";
//class GTextFiledBitmap
    
    export  class GTextFiledBitmap /* flash.display.Bitmap */ implements IDispose
    {
        constructor(arg1: Object /* flash.display.BitmapData */=null, arg2: string="auto", arg3: Boolean=false)
        {
            super(arg1, arg2, arg3);
            return;
        }

        public set txtWidth(arg1: number)
        {
            this._txtWidth = arg1;
            return;
        }

        public get txtWidth(): number
        {
            return this._txtWidth;
        }

        public set txtHeight(arg1: number)
        {
            this._txtHeight = arg1;
            return;
        }

        public get txtHeight(): number
        {
            return this._txtHeight;
        }

        public set txtFilters(arg1: Array<any>)
        {
            this._filters = arg1;
            return;
        }

        public set textFormat(arg1: Object /* flash.text.TextFormat */)
        {
            this._textFormat = arg1;
            return;
        }

        public set text(arg1: string)
        {
            this._text = arg1;
            this.draw(arg1, false);
            return;
        }

        public get text(): string
        {
            return this._text;
        }

        public set htmlText(arg1: string)
        {
            this._htmlText = arg1;
            this.draw(arg1, true);
            return;
        }

        public get htmlText(): string
        {
            return this._htmlText;
        }

        /* internal  */draw(arg1: string, arg2: Boolean): void
        {
            if (GTextFiledBitmap.textFiled.defaultTextFormat != this._textFormat) 
            {
                GTextFiledBitmap.textFiled.defaultTextFormat = this._textFormat;
            }
            if (arg2) 
            {
                GTextFiledBitmap.textFiled.htmlText = arg1;
            }
            else 
            {
                GTextFiledBitmap.textFiled.text = arg1;
            }
            GTextFiledBitmap.textFiled.width = this._txtWidth;
            GTextFiledBitmap.textFiled.height = this._txtHeight;
            GTextFiledBitmap.textFiled.filters = this._filters;
            this.bitmapData = this._bitmapDataClone;
            this.bitmapData.draw(GTextFiledBitmap.textFiled);
            return;
        }

        public /* override */ set bitmapData(arg1: Object /* flash.display.BitmapData */)
        {
            this._bitmapDataClone = arg1.clone();
            super.bitmapData = arg1;
            return;
        }

        public dispose(arg1: Boolean=true): void
        {
            this._text = "";
            this._htmlText = "";
            this._txtWidth = 0;
            this._txtHeight = 0;
            this._textFormat = null;
            this._filters = null;
            this._bitmapDataClone.dispose();
            this.bitmapData.dispose();
            this._bitmapDataClone = null;
            if (this.parent) 
            {
                this.parent.removeChild(this);
            }
            if (arg1) 
            {
                UICompomentPool.disposeUICompoment(this);
            }
            return;
        }

        private /* var */_txtWidth: number;

        private /* var */_txtHeight: number;

        private /* var */_filters: Array<any>;

        private /* var */_textFormat: Object /* flash.text.TextFormat */;

        private /* var */_text: string;

        private /* var */_htmlText: string;

        private /* var */_bitmapDataClone: Object /* flash.display.BitmapData */;

        public static /* var */textFiled: GTextFiled;
    }

            GTextFiledBitmap.textFiled = new GTextFiled();
            textFiled.GTextFiledBitmap.multiline = true;
            textFiled.GTextFiledBitmap.wordWrap = true;
        